import 'package:daoyi_ui_admin_getx/app/routes/app_pages.dart';
import 'package:daoyi_ui_admin_getx/generated/locales.g.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';

import 'login_controller.dart';

class LoginView extends GetView<LoginController> {
  const LoginView({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(LocaleKeys.pages_login_title.tr),
        centerTitle: true,
      ),
      body: SafeArea(
        minimum: const EdgeInsets.all(30),
        child: ListView(
          children: <Widget>[
            TextField(
              decoration: InputDecoration(
                labelText: LocaleKeys.pages_login_tenant.tr,
                hintText:
                    '${LocaleKeys.commons_pls_enter.tr}${LocaleKeys.pages_login_tenant.tr}',
              ),
            ),
            const SizedBox(
              height: 20,
            ),
            TextField(
              decoration: InputDecoration(
                labelText: LocaleKeys.pages_login_username.tr,
                hintText:
                    '${LocaleKeys.commons_pls_enter.tr}${LocaleKeys.pages_login_username.tr}',
              ),
            ),
            const SizedBox(
              height: 20,
            ),
            Obx(
              () => TextField(
                obscureText: !controller.showPassword.value,
                decoration: InputDecoration(
                  labelText: LocaleKeys.pages_login_password.tr,
                  hintText:
                      '${LocaleKeys.commons_pls_enter.tr}${LocaleKeys.pages_login_password.tr}',
                  suffixIcon: IconButton(
                    onPressed: () {
                      controller.changeShowPassword();
                    },
                    icon: Icon(controller.showPassword.value
                        ? Icons.visibility_off_outlined
                        : Icons.visibility_outlined),
                  ),
                ),
              ),
            ),
            const SizedBox(
              height: 20,
            ),
            ElevatedButton(
              onPressed: () {
                Get.offAllNamed(Routes.TABS, parameters: {'current': '3'});
              },
              child: Text(
                LocaleKeys.buttons_login.tr,
              ),
            ),
            Row(
              mainAxisAlignment: MainAxisAlignment.center,
              children: <Widget>[
                Text("${LocaleKeys.pages_login_no_account.tr}，"),
                TextButton(
                  onPressed: () {
                    Get.offAllNamed(Routes.REGISTER);
                  },
                  child: Text(
                      "${LocaleKeys.commons_to.tr}${LocaleKeys.pages_register_title.tr}~"),
                ),
              ],
            ),
            const SizedBox(
              height: 20,
            ),
            TextButton(
              onPressed: () {
                Get.toNamed(Routes.FORGET_PASSWORD);
              },
              child: Text("${LocaleKeys.pages_login_forgot_password.tr}？"),
            ),
            const SizedBox(
              height: 20,
            ),
            TextButton(
              onPressed: () {
                Get.offAllNamed(AppPages.INITIAL);
              },
              child: Text(
                  "${LocaleKeys.buttons_back.tr}${LocaleKeys.tabs_home.tr}"),
            ),
          ],
        ),
      ),
    );
  }
}
